From aa9a5f72391ea240eb51427852d807fffd607fa3 Mon Sep 17 00:00:00 2001 From: Steven Hand Date: Fri, 1 Sep 2006 13:52:04 +0100 Subject: [PATCH] More hvm common-code cleanups. Signed-off-by: Steven Hand --- xen/arch/x86/hvm/svm/intr.c | 41 +++++++++++++++++-------------------- xen/arch/x86/hvm/vlapic.c | 14 +++++++++++++ xen/arch/x86/hvm/vmx/io.c | 13 ------------ 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/xen/arch/x86/hvm/svm/intr.c b/xen/arch/x86/hvm/svm/intr.c index d0b5c2d6ce..d053c6d122 100644 --- a/xen/arch/x86/hvm/svm/intr.c +++ b/xen/arch/x86/hvm/svm/intr.c @@ -79,22 +79,22 @@ asmlinkage void svm_intr_assist(void) ASSERT(vmcb); /* Check if an Injection is active */ - /* Previous Interrupt delivery caused this Intercept? */ - if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0)) { - v->arch.hvm_svm.saved_irq_vector = vmcb->exitintinfo.fields.vector; + /* Previous Interrupt delivery caused this Intercept? */ + if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0)) { + v->arch.hvm_svm.saved_irq_vector = vmcb->exitintinfo.fields.vector; // printk("Injecting PF#: saving IRQ from ExitInfo\n"); - vmcb->exitintinfo.bytes = 0; - re_injecting = 1; - } + vmcb->exitintinfo.bytes = 0; + re_injecting = 1; + } /* Guest's interrputs masked? */ rflags = vmcb->rflags; if (irq_masked(rflags)) { HVM_DBG_LOG(DBG_LEVEL_1, "Guest IRQs masked: rflags: %lx", rflags); - /* bail out, we won't be injecting an interrupt this time */ - return; + /* bail out, we won't be injecting an interrupt this time */ + return; } - + /* Previous interrupt still pending? */ if (vmcb->vintr.fields.irq) { // printk("Re-injecting IRQ from Vintr\n"); @@ -115,27 +115,24 @@ asmlinkage void svm_intr_assist(void) if ( v->vcpu_id == 0 ) hvm_pic_assist(v); - callback_irq = v->domain->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ]; - /* Before we deal with PIT interrupts, let's check for - interrupts set by the device model or paravirtualised event - channel interrupts. - */ - if ( cpu_has_pending_irq(v) ) { - intr_vector = cpu_get_interrupt(v, &intr_type); + if ( (v->vcpu_id == 0) && pt->enabled && pt->pending_intr_nr ) { + pic_set_irq(pic, pt->irq, 0); + pic_set_irq(pic, pt->irq, 1); } - else if ( callback_irq != 0 && local_events_need_delivery() ) { + + callback_irq = v->domain->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ]; + if ( callback_irq != 0 && + local_events_need_delivery() ) { /*inject para-device call back irq*/ v->vcpu_info->evtchn_upcall_mask = 1; pic_set_irq(pic, callback_irq, 0); pic_set_irq(pic, callback_irq, 1); - intr_vector = callback_irq; } - else if ( (v->vcpu_id == 0) && pt->enabled && pt->pending_intr_nr ) { - pic_set_irq(pic, pt->irq, 0); - pic_set_irq(pic, pt->irq, 1); + + if ( cpu_has_pending_irq(v) ) intr_vector = cpu_get_interrupt(v, &intr_type); - } + } /* have we got an interrupt to inject? */ diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 9cb27656c3..bedb877942 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -919,6 +919,20 @@ int cpu_has_apic_interrupt(struct vcpu* v) return 0; } +/* check to see if there is pending interrupt */ +int cpu_has_pending_irq(struct vcpu *v) +{ + struct hvm_domain *plat = &v->domain->arch.hvm_domain; + + /* APIC */ + if ( cpu_has_apic_interrupt(v) ) return 1; + + /* PIC */ + if ( !vlapic_accept_pic_intr(v) ) return 0; + + return plat->interrupt_request; +} + void vlapic_post_injection(struct vcpu *v, int vector, int deliver_mode) { struct vlapic *vlapic = VLAPIC(v); diff --git a/xen/arch/x86/hvm/vmx/io.c b/xen/arch/x86/hvm/vmx/io.c index 6ac5340181..f5133b3ce2 100644 --- a/xen/arch/x86/hvm/vmx/io.c +++ b/xen/arch/x86/hvm/vmx/io.c @@ -68,19 +68,6 @@ static inline int is_interruptibility_state(void) return interruptibility; } -/* check to see if there is pending interrupt */ -int cpu_has_pending_irq(struct vcpu *v) -{ - struct hvm_domain *plat = &v->domain->arch.hvm_domain; - - /* APIC */ - if ( cpu_has_apic_interrupt(v) ) return 1; - - /* PIC */ - if ( !vlapic_accept_pic_intr(v) ) return 0; - - return plat->interrupt_request; -} asmlinkage void vmx_intr_assist(void) { -- 2.30.2